﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Tomato.Serialization
{
    public abstract class Serializer
    {
        public abstract void Serialize(Stream stream, object obj);

        public string Serialize(object obj)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                Serialize(stream, obj);
                return Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length);
            }
        }
    }
}
